package com.clear.state.fsm.state;

/**
 * 具体状态类：实现大马里奥状态
 */
public class BigMario implements MarioState {

    private Mario mario;

    public BigMario(Mario mario) {
        this.mario = mario;
    }

    @Override
    public void handleEvent(Event event) {
        switch (event) {
            case MUSHROOM -> {   // jdk17新写法
                System.out.println("保持大马里奥");
            }
            case FIRE_FLOWER -> {
                System.out.println("大马里奥变为火焰马里奥");
                mario.setState(new FireMario(mario));
            }
            case ENEMY_ATTACK -> {
                System.out.println("大马里奥变为小马里奥");
                mario.setState(new SmallMario(mario));
            }
            case FALL_INTO_PIT -> {
                System.out.println("大玛丽奥去世了");
                mario.setState(new DeadMario(mario));
            }
        }
    }
}
